package GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

/**
* Classe AboutDialog  
* Boîte de dialogue qui s'ouvre lorsqu'on click sur l'onglet "A propos"
* @author      Frank Djomo
 * @author      Christelle SIAGO HAPPI
 * @author      djomopoueme@gmail.com
 * @author      christelle.siagohappi@gmail.com
* @version     1.0
*/

public class AboutDialog extends JDialog{

    private JButton closeButton;
    private JPanel  panel;
    private JLabel  label_appName,label_appBuild,label_author,label_author2;
    private JLabel  label_email,label_email2,label_framework,label_website;
   


    /**
     * Crée la boite de dialogue
     * @param parent        nom de la JFrame qui contient la fenetre
     * @param appName       nom de l'application
     * @param appVersion    Version de l'application    
     * @param appBuild      Date de la dernière mise à jour
     */
    public AboutDialog(JFrame parent, String appName, String appVersion, String appBuild)
    {
        super(parent,true);
        //Definition de la police
        init(appName,appVersion,appBuild);
    }

    
    /**
     * Initialise cet AboutDialog
     * @param appName       nom de l'application
     * @param appVersion    Version de l'application    
     * @param appBuild      Date de la dernière mise à jour
     */
    private void init(String appName, String appVersion, String appBuild)
    {
        //Option de la fenetre
        setTitle("A Propos");
        setSize(220, 220);
        getContentPane().setLayout(new BorderLayout());
        setLocationRelativeTo(null);
        Font font = new Font("Cambria", Font.BOLD, 15);

        addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e)
            {dispose();}
        });

        panel = new JPanel();
        panel.setLayout(new FlowLayout());

        closeButton = new JButton("Fermer");
        closeButton.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e)
            { dispose();}
        });

        //Image img = (new ImageIcon(getClass().getResource("/Ressources/images/app.gif"))).getImage();
        //Icon app = new ImageIcon(img.getScaledInstance(16,16,16));

        label_appName = new JLabel(appName,null,SwingConstants.LEFT);
        label_appName.setFont(font);
        label_appName.setForeground(Color.RED);

        label_appBuild = new JLabel("version "+appVersion+"\n");
        label_appBuild.setFont(font);
        label_appBuild.setForeground(Color.RED);

        label_author = new JLabel("Franck Djomo\n\n");
        label_author2 = new JLabel("Christelle Siago happi\n\n");

        label_author.setForeground(Color.BLUE);
        label_author2.setForeground(Color.BLUE);
        

        label_framework = new JLabel("Copyright (c) 2013 InsaTeam\n");
        label_website = new JLabel("http://www.insa-toulouse.fr\n");
        label_email = new JLabel("djomopoueme@gmail.com\n\n");
        label_email2 = new JLabel("christelle.siagohappi@gmail.com\n\n");

        

        label_email.setForeground(Color.GRAY);
        label_email2.setForeground(Color.GRAY);

        label_framework.setForeground(Color.BLACK);
        label_website.setForeground(Color.BLACK);

        font = new Font(Font.DIALOG, Font.BOLD, 12);

        label_appName.setFont(font);
        label_appBuild.setFont(font);
        label_author.setFont(font);
        label_email.setFont(font);
        label_framework.setFont(font);
        label_website.setFont(font);



        panel.add(label_appName);
        panel.add(new JLabel(" "));
        panel.add(label_appBuild);
        panel.add(new JLabel(" "));
        panel.add(label_author);
        panel.add(new JLabel(" "));
        panel.add(label_author2);
        panel.add(new JLabel(" "));
        panel.add(label_email);
        panel.add(new JLabel(" "));
        panel.add(label_email2);
        panel.add(new JLabel(" "));
        panel.add(label_framework);
        panel.add(label_website);

        panel.add(new JLabel(" "));
        closeButton.setHorizontalTextPosition(SwingConstants.CENTER);
        panel.add(closeButton);

        getContentPane().add("Center", panel);
      }
}
